/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.dusin.commonutil;

/**
 *
 * @author zuohan
 */
public class TheUtil {
    // 调整月数据最大值时、最小值时在正确的范围内
    public static String correctDate(String year,String month,String day){
        StringBuilder sb = new StringBuilder();
        int iday = Integer.parseInt(day);
        int imonth = Integer.parseInt(month);
        int iyear = Integer.parseInt(year);
        if(iday>=20){
            imonth=imonth-1;
        }
        if(imonth==0){
            iyear = iyear -1;
            imonth = 12;
        }
        sb.append(iyear).append("-");
        if(imonth<10){
            sb.append("0");
        }
        sb.append(imonth).append("-");
        if(iday<10){
            sb.append("0");
        }
        sb.append(iday);
        return sb.toString();
    }
}
